//@target illustrator

String.prototype.clearSpace = function(){
  return this.replace(/(^\s*)|(\s*$)/g, "")
}
String.prototype.toAiColor = function(){
  // 支持字符格式为: '100 70 30 0, 128 256 0' 或者 '128 0 0' (rgb 可使用 HEX)
  var colors = this.clearSpace().split(',')
  color = colors[0].hex2rgb().split(' ')
  var isRGBSpace = app.activeDocument.documentColorSpace === DocumentColorSpace.RGB
  if (colors.length === 2 && isRGBSpace) {
    color = colors[1].clearSpace().hex2rgb().split(' ')
  }
  try {
    if(color.length === 3) {
      var newColor = new RGBColor();
      newColor.red = color[0];
      newColor.green = color[1];
      newColor.blue = color[2];
    } else if(color.length === 4) {
      var newColor = new CMYKColor();
      newColor.cyan = color[0];
      newColor.magenta = color[1];
      newColor.yellow = color[2];
      newColor.black = color[3];
    }
    return newColor
  } catch (e) {
    var newColor = new RGBColor();
    newColor.red = 0;
    newColor.green = 0;
    newColor.blue = 0;
  }
  return newColor
}

String.prototype.hex2rgb = function(){
  // '#888' => '128 128 128'
  var sColor = this.toLowerCase();
  //十六进制颜色值的正则表达式
  var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  // 如果是16进制颜色
  if (sColor && reg.test(sColor)) {
    if (sColor.length === 4) {
      var sColorNew = "#";
      for (var i=1; i<4; i+=1) {
        sColorNew += sColor.slice(i, i+1).concat(sColor.slice(i, i+1));
      }
      sColor = sColorNew;
    }
    //处理六位的颜色值
    var sColorChange = [];
    for (var i=1; i<7; i+=2) {
      sColorChange.push(parseInt("0x"+sColor.slice(i, i+2)));
    }
    return sColorChange.join(" ");
  }
  return sColor;
};


var svgCode = '''
<svg version="1.1" id="Logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 912 300" style="enable-background:new 0 0 912 300;" xml:space="preserve">

<path   d="M289.29,270.31c-1.02,0-2.04,0-3.06,0l-10.45,28.99h6.18l1.85-5.86h5.48h5.35l1.92,5.86h6.18l-10.45-28.99
	C291.26,270.31,290.25,270.31,289.29,270.31z M289.29,288.22h-3.76l3.69-11.54l0.06,0.06l3.7,11.47H289.29z M70.66,223.16H0.96
	v-12.55h69.71V223.16z M197.85,222.33h-25.04v-11.98h25.04V222.33z M130.56,185.12h31.22v10.77h-36.83
	c-2.11,2.87-4.65,3.06-9.69,3.06h-5.92v-11.85h2.42c2.3,0,3.19-0.26,4.34-1.97l1.78-2.8h14.33L130.56,185.12z M85.95,218.77
	l-4.84-13.19h13.57l2.68,6.37c0.7,1.98,2.24,2.42,4.27,2.42h3.44l0.07,10.71H96.6C91.25,225.07,87.93,224.11,85.95,218.77z
	 M109.34,201.82h52.44v10.38h-52.44V201.82z M109.34,217.62h52.44v9.69l-26.83,16.88h26.83v10.77h-52.25v-9.75l28.48-17.01h-28.67
	V217.62z M105.33,229.98l-4.21,16.51c-1.79,7.01-5.42,8.47-12.23,8.47h-7.07v-10.89h2.17c2.87,0,3.83-0.7,4.59-3.18l3.06-10.9
	H105.33z M86.46,195.64L82,183.27h13.51l1.97,5.42c0.7,1.91,1.72,2.23,3.76,2.23h3.89v10.83h-6.5
	C92.71,201.75,88.57,201.43,86.46,195.64z M382.77,244.06v10.89h-6.88c-5.86,0-7.52-1.08-9.05-7.52l-3.65-14.94l-4.7,15.2
	c-1.98,6.37-3.63,7.26-9.75,7.26h-6.18v-10.89h1.08c2.16,0,2.67-1.08,3.51-3.76l8.35-26.57H369l-2.5,8.09h6.91l4.9,18.67
	c0.7,2.68,1.27,3.57,3.44,3.57H382.77z M338.86,254.95h-6.88c-5.86,0-7.45-1.08-9.05-7.52l-3.61-14.96l-4.74,15.21
	c-1.97,6.37-3.63,7.26-9.75,7.26h-6.12v-10.89h0.89c2.16,0,2.67-1.08,3.51-3.76l8.47-26.57h13.57l-2.52,8.09h6.85l4.9,18.67
	c0.76,2.68,1.27,3.57,3.45,3.57h1.02V254.95z M309.23,210.99h-7.65v-10.77h2.22c2.16,0,3.38,0,5.16-3.75l6.12-13.19h52.44
	l6.12,13.19c1.72,3.75,3.06,3.75,5.23,3.75h2.1v10.77h-7.14c-5.54,0-8.47-1.08-11.02-6.24l-4.71-9.44c-10.77,0-22.88,0-33.64,0
	l-4.34,9.44C317.71,209.97,314.77,210.99,309.23,210.99z M212.63,254.95h-5.86v-10.89h2.04c3.63,0,5.29-1.21,7.32-4.33l20.72-34.85
	h-29.82v-11.98h32.5v-10.45h15.3v10.45h32.63v11.98h-29.82l20.71,34.85c2.04,3.12,3.32,4.33,7.01,4.33h2.36v10.89h-5.86
	c-7.9,0-11.21,0-15.61-7.45l-18.98-31.73l-18.99,31.73C223.78,254.95,220.47,254.95,212.63,254.95z M32.81,270.5
	c-1.02,0-2.04,0-3.06,0L19.3,299.5h6.18l1.91-5.86h5.42h5.42l1.84,5.86h6.18L35.88,270.5C34.85,270.5,33.83,270.5,32.81,270.5z
	 M32.81,288.41h-3.76l3.76-11.47l3.76,11.47H32.81z M0.82,270.5c4.97,0,9.94,0,14.91,0v5.48H6.56v6.05h9.18v5.48H6.56v11.98H0.82
	V270.5z M87.55,284.01h11.22v4.97H87.55V284.01z M124.63,270.5h6.18l-10.45,28.99c-2.04,0-4.08,0-6.12,0L103.8,270.5h6.18
	l7.33,22.62L124.63,270.5z M147.38,270.18c-9.31,0-13.77,6.69-13.77,14.79c0,8.22,4.46,14.91,13.77,14.91
	c9.23,0,13.76-6.69,13.76-14.91C161.14,276.88,156.62,270.18,147.38,270.18z M147.38,295.04c-5.42,0-7.9-4.53-7.9-10.07
	c0-5.48,2.48-9.94,7.9-9.94c5.35,0,7.84,4.46,7.84,9.94C155.22,290.51,152.73,295.04,147.38,295.04z M173.44,294.59h9.43v4.9H167.9
	V270.5h5.54V294.59z M199.95,284.46l11.09,15.03h-7.34l-9.3-13.95v13.95h-5.54V270.5h5.54v13.13l9.37-13.13h6.75L199.95,284.46z
	 M232.96,290.51c0.25,4.46-2.23,8.03-6.37,9.05c-3.13,0.7-7.33,0.51-10.58-0.19v-5.29c1.59,0.58,3.88,1.02,5.99,1.02
	c2.8,0,5.03-1.15,5.03-3.82c0-5.54-11.85-3.38-12.17-12.55c-0.19-5.16,4.08-8.73,11.02-8.73c1.53,0,3.31,0.32,4.97,0.58v4.91v0.06
	c-1.66-0.51-3.44-0.89-5.23-0.89c-3.18,0-4.84,1.46-4.84,3.57C220.79,283.31,232.45,281.34,232.96,290.51z M269.67,270.31h5.54
	l-7.33,28.99c-2.23,0-4.52,0-6.75,0l-5.16-20.52l-5.16,20.52c-2.23,0-4.53,0-6.76,0l-7.33-28.99h5.54l5.22,21.47l5.55-21.47
	c1.97,0,3.88,0,5.86,0l5.55,21.47L269.67,270.31z M323.76,284.08h5.61v14.34c-10.9,3.69-24.53,0.76-24.53-13.38
	c0-9.05,6.18-15.17,16.18-15.17c2.87,0,5.74,0.45,8.22,1.21v5.48c-7.26-2.99-18.03-2.16-18.29,8.35c-0.19,7.58,5.99,11.15,12.8,9.3
	V284.08z M336.37,270.31h15.74v4.72h-10.13v7.07h9.62v4.59h-9.62v7.84h10.13v4.78h-15.74V270.31z M376.96,270.31h5.23v28.99h-6.94
	l-11.73-20.01v20.01h-5.29v-28.99h6.95l11.79,20.07V270.31z M77.42,270.5h5.54l-7.58,28.99c-2.17,0-4.33,0-6.44,0l-4.08-19.82
	l-4.07,19.82h-1.21H55.5h-1.21L46.7,270.5h5.54l5.1,20.27l4.33-20.27c2.1,0,4.2,0,6.37,0l4.27,20.27L77.42,270.5z"/>
<path   d="M313.12,143.29c-37.34,0-67.98-30.84-67.98-68.19c0-8.39,1.47-16.36,4.3-23.81l39.76,80.04
	c0.52,1.06,1.15,1.89,2.41,1.89c1.26,0,1.95-0.85,2.41-1.89l18.25-41.02c0.21-0.42,0.42-0.84,0.84-0.84s0.63,0.42,0.84,0.84
	l18.25,41.02c0.46,1.03,1.15,1.89,2.41,1.89c1.26,0,1.89-0.84,2.41-1.89L376.8,51.3c2.83,7.45,4.3,15.42,4.3,23.81
	C381.1,112.45,350.47,143.29,313.12,143.29 M313.12,59.69c-0.42,0-0.63-0.42-0.84-0.84l-21.4-48.04c6.92-2.52,14.48-3.88,22.24-3.88
	s15.32,1.36,22.24,3.88l-21.4,48.04C313.75,59.27,313.54,59.69,313.12,59.69 M291.41,108.99c-0.42,0-0.63-0.42-0.84-0.84
	l-34.62-69.76c6.19-9.44,14.48-17.41,24.44-22.97l24.86,55.39c0.42,1.05,1.05,1.26,1.89,1.26h11.96c0.84,0,1.47-0.21,1.89-1.26
	l24.86-55.39c9.97,5.56,18.25,13.53,24.44,22.97l-34.62,69.76c-0.21,0.42-0.42,0.84-0.84,0.84c-0.42,0-0.63-0.42-0.84-0.84
	l-13.01-29.79c-0.42-1.05-1.05-1.26-1.89-1.26h-11.96c-0.84,0-1.47,0.21-1.89,1.26l-13.01,29.79
	C292.04,108.57,291.83,108.99,291.41,108.99 M313.12,150.22c41.54,0,75.11-33.57,75.11-75.11S354.66,0,313.12,0
	c-41.54,0-75.11,33.57-75.11,75.11S271.58,150.22,313.12,150.22 M105.11,12.11c26.59,0,51.49,6.84,70.11,19.25
	c17.73,11.82,27.5,27.25,27.5,43.46s-9.77,31.63-27.5,43.46c-18.62,12.41-43.52,19.25-70.11,19.25S53.62,130.69,35,118.28
	C17.26,106.45,7.5,91.02,7.5,74.82S17.26,43.19,35,31.37C53.62,18.95,78.52,12.11,105.11,12.11 M105.11,4.75
	C47.06,4.75,0,36.12,0,74.82s47.06,70.07,105.11,70.07c58.05,0,105.11-31.37,105.11-70.07S163.16,4.75,105.11,4.75L105.11,4.75z
	 M87.65,100.98V88.27l-12.71,6.6h-33.4l2.91,7.11c1.22,2.79,4.19,4.63,7.26,4.63h25.09L87.65,100.98z M113.52,110.49V24.84h-6.48
	L91.3,31.38c0,0-2.11,0.74-2.11,2.99s0,4.96,0,4.96h4.62c1.77,0,2.88,1.09,2.88,2.82l0,0.97v67.35c0,1.83-1.2,3.02-3.07,3.02h-5.98
	v11.31h34.92V113.5h-5.98C114.72,113.5,113.52,112.32,113.52,110.49z M87.65,62.63V50.89H23.47L26.41,58
	c1.22,2.79,4.16,4.63,7.24,4.63H87.65z M87.65,83.08V71.34H31.87l2.94,7.11c1.22,2.79,4.16,4.63,7.24,4.63H87.65z M168.17,83.08
	c3.07,0,6.02-1.84,7.24-4.63l2.94-7.11h-55.77v11.74H168.17z M136.25,50.89v-3.26h-13.67v3.26h0v11.74h54
	c3.07,0,6.02-1.84,7.24-4.63l2.94-7.11H136.25z M145.84,94.87L135,89.23h-12.43v11.74h10.65l10.84,5.63h14.45
	c3.07,0,6.04-1.84,7.26-4.63l2.91-7.11H145.84z"/>
<rect   x="462.52" width="3" height="300"/>
<path   d="M859.29,163.07c-2.18-1.95-5.11-2.93-8.78-2.93c-3.49,0-6.23,0.98-8.23,2.93c-1.95,2.05-2.93,4.49-2.93,7.32
	c0,3.11,0.84,5.58,2.51,7.39c1.81,1.86,4.07,2.79,6.76,2.79c1.25,0,2.35-0.19,3.28-0.56l-6.9,10.11v0.42h6.62l8.3-12.76
	c1.53-2.32,2.3-4.79,2.3-7.39C862.22,167.56,861.24,165.12,859.29,163.07 M845.56,170.39c0-1.67,0.42-2.9,1.25-3.7
	c0.93-0.84,2.16-1.26,3.7-1.25c1.67,0,2.97,0.42,3.9,1.25c0.93,0.79,1.39,2.02,1.39,3.7c0,3.21-1.77,4.81-5.3,4.81
	C847.21,175.2,845.56,173.6,845.56,170.39 M816.49,185.52v5.02h18.48v-5.02h-5.86v-24.75h-4.39l-7.6,2.58v5.02h0.7l5.3-1.67v18.82
	H816.49 M782.81,105.28h-9.34v44.97h9.34V105.28 M831.54,105.28h-9.34v31.09l-19.38-31.09h-9.55v44.97h9.13v-31.16l19.38,31.16h9.76
	V105.28 M849.11,127.66c0-4.88,1.02-8.65,3.07-11.29c2.09-2.84,5.09-4.25,8.99-4.25c3.44,0,6.93,0.7,10.46,2.09l2.37-7.18
	c-4.14-1.91-8.41-2.86-12.83-2.86c-6.88,0-12.27,2.18-16.17,6.55c-3.67,4.18-5.51,9.83-5.51,16.94c0,7.2,1.84,12.85,5.51,16.94
	c3.9,4.42,9.3,6.62,16.17,6.62c4.42,0,8.69-1.05,12.83-3.14l-2.37-7.18c-3.53,1.49-7.02,2.23-10.46,2.23c-3.9,0-6.9-1.32-8.99-3.97
	C850.14,136.32,849.11,132.49,849.11,127.66 M894.22,168.37h0.7l5.23-1.67v18.82h-6.62v5.02H912v-5.02h-5.86v-24.75h-4.39
	l-7.53,2.58V168.37 M885.09,163.07c-2.18-1.95-5.09-2.93-8.71-2.93c-3.53,0-6.27,0.98-8.23,2.93c-2,2.05-3,4.49-3,7.32
	c0,3.11,0.84,5.58,2.51,7.39c1.86,1.86,4.16,2.79,6.9,2.79c1.21,0,2.28-0.19,3.21-0.56l-6.83,10.11v0.42h6.62l8.16-12.76
	c1.58-2.32,2.37-4.79,2.37-7.39C888.09,167.56,887.09,165.12,885.09,163.07 M880.28,166.7c0.93,0.79,1.39,2.02,1.39,3.7
	c0,3.21-1.77,4.81-5.3,4.81c-3.35,0-5.02-1.6-5.02-4.81c0-1.67,0.46-2.9,1.39-3.7c0.88-0.84,2.09-1.26,3.63-1.25
	C878,165.44,879.3,165.86,880.28,166.7 M909.63,123.54h-18.75v-10.67h20.85v-7.6H881.6v44.97H912v-7.74h-21.12v-11.36h18.75V123.54
	 M753.74,123.82l-4.81-1.74c-3.02-0.84-4.53-2.42-4.53-4.74c0-3.67,2.3-5.51,6.9-5.51c3.25,0,6.74,1.02,10.46,3.07l2.72-7.53
	c-4.14-2.14-8.53-3.21-13.18-3.21c-5.3,0-9.3,1.28-11.99,3.83c-2.84,2.56-4.25,5.93-4.25,10.11c0,5.9,3.56,10.02,10.67,12.34
	l4.95,1.74c2.23,0.65,3.83,1.35,4.81,2.09c0.88,0.93,1.32,2.07,1.32,3.42c0,3.63-2.51,5.44-7.53,5.44c-1.81,0-4.02-0.33-6.62-0.98
	c-2.23-0.6-4.04-1.39-5.44-2.37l-3.21,6.83c5.11,3.07,10.2,4.6,15.27,4.6c5.3,0,9.46-1.25,12.48-3.76
	c2.97-2.56,4.46-6.04,4.46-10.46c0-3.39-1.07-6.16-3.21-8.3C761.24,126.89,758.15,125.26,753.74,123.82z M609.63,61.49
	c-0.9-0.74-1.92-1.11-3.07-1.12h-61.84c-1.35,0-2.51,0.46-3.49,1.39c-0.93,0.98-1.39,2.14-1.39,3.49c0,1.35,0.46,2.49,1.39,3.42
	c0.98,0.98,2.14,1.46,3.49,1.46h53.75l-26.42,50.55c-0.52,1.02-0.68,2.07-0.49,3.14c0.21,1.11,0.72,2.04,1.53,2.79
	c0.85,0.75,1.83,1.17,2.93,1.25c10.28,0.72,19.18,4.86,26.7,12.41c8.46,8.46,12.69,18.61,12.69,30.47c0,11.94-4.23,22.1-12.69,30.47
	c-8.37,8.45-18.48,12.68-30.33,12.69c-3.33,0-6.54-0.32-9.62-0.98h0.07c-5.57-1.18-10.66-3.44-15.27-6.76
	c-1.09-0.78-2.3-1.06-3.63-0.84c-1.32,0.21-2.39,0.86-3.21,1.95c-0.77,1.09-1.05,2.3-0.84,3.63c0.21,1.33,0.86,2.4,1.95,3.21
	c5.71,4.11,12,6.9,18.89,8.37h0.07c3.71,0.79,7.56,1.18,11.57,1.19c14.55,0,26.96-5.18,37.23-15.55
	c10.37-10.27,15.55-22.73,15.55-37.37c0-14.54-5.18-27-15.55-37.37c-7.46-7.5-16.03-12.27-25.73-14.29l26.98-51.59
	c0.54-1.01,0.68-2.07,0.42-3.21C611.09,63.15,610.53,62.22,609.63,61.49 M703.61,6c-0.22-1.1-0.77-2.03-1.67-2.79
	c-0.89-0.7-1.92-1.05-3.07-1.05H544.72c-1.35,0-2.51,0.46-3.49,1.39c-0.93,0.98-1.39,2.14-1.39,3.49s0.46,2.49,1.39,3.42
	c0.98,0.98,2.14,1.46,3.49,1.46h146.13l-35.28,68.32c-0.36,0.69-0.55,1.41-0.56,2.16c0,0.8,0.16,1.55,0.49,2.23
	c0.26,0.54,0.63,1.05,1.12,1.53c23.42,23.42,35.14,51.61,35.14,84.57c0,33-11.72,61.12-35.14,84.36
	c-23.24,23.42-51.39,35.14-84.43,35.14c-3.36-0.01-6.7-0.14-10.04-0.42l0,0c-5.62-0.4-11.08-1.19-16.38-2.37
	c-1.31-0.26-2.54-0.03-3.7,0.7c-1.12,0.73-1.84,1.75-2.16,3.07c-0.27,1.31-0.03,2.52,0.7,3.63c0.73,1.17,1.75,1.89,3.07,2.16
	c5.76,1.28,11.68,2.14,17.78,2.58c3.55,0.28,7.13,0.42,10.74,0.42c35.74,0,66.19-12.66,91.33-38c25.33-25.14,38-55.56,38-91.26
	c0-34.57-11.9-64.29-35.7-89.17l37.37-72.3C703.73,8.24,703.87,7.14,703.61,6 M650.83,32.28c-0.88-0.7-1.88-1.04-3-1.05H544.72
	c-1.35,0-2.51,0.46-3.49,1.39c-0.93,0.98-1.39,2.14-1.39,3.49c0,1.35,0.46,2.49,1.39,3.42c0.98,0.98,2.14,1.46,3.49,1.46h95.51
	l-25.52,55.78c-0.49,1.1-0.58,2.22-0.28,3.35c0.36,1.17,1.04,2.08,2.02,2.72c4.54,3.01,8.87,6.56,12.97,10.67
	c15.85,15.89,23.77,34.97,23.77,57.24c0,22.36-7.93,41.41-23.77,57.17c-15.76,15.85-34.79,23.77-57.1,23.77
	c-3.4,0-6.75-0.18-10.04-0.56c-5.57-0.59-10.92-1.75-16.04-3.49c-1.28-0.4-2.53-0.31-3.76,0.28c-1.18,0.63-1.99,1.58-2.44,2.86
	c-0.4,1.28-0.31,2.51,0.28,3.7c0.63,1.23,1.58,2.04,2.86,2.44c5.76,1.94,11.78,3.24,18.06,3.9c3.63,0.42,7.33,0.62,11.09,0.63
	c25.01,0,46.34-8.88,64-26.63c17.76-17.66,26.63-39.02,26.63-64.07c0-24.96-8.88-46.34-26.63-64.14c-3.53-3.53-7.2-6.69-11.02-9.48
	l26.91-58.98c0.5-1.03,0.61-2.1,0.35-3.21C652.3,33.86,651.72,32.98,650.83,32.28z M693.08,239.34c0.21,1.33,0.86,2.4,1.95,3.21
	c19.05,13.75,40.92,20.63,65.61,20.64c31.42,0,58.22-11.11,80.39-33.33c6.23-6.18,11.58-12.73,16.04-19.66
	c0.73-1.13,0.94-2.36,0.63-3.7c-0.26-1.29-0.96-2.31-2.09-3.07c-1.13-0.72-2.36-0.95-3.7-0.7c-1.3,0.31-2.32,1.03-3.07,2.16
	c-4.09,6.36-9,12.38-14.71,18.06c-20.27,20.31-44.76,30.47-73.48,30.47c-22.54,0.01-42.5-6.27-59.89-18.82
	c-1.09-0.78-2.3-1.06-3.63-0.84c-1.32,0.21-2.39,0.86-3.21,1.95C693.15,236.81,692.87,238.02,693.08,239.34 M705.7,202.32
	c0.03,1.37,0.52,2.51,1.46,3.42c14.91,14.26,32.73,21.4,53.47,21.4c17.87-0.02,33.53-5.27,46.99-15.76
	c1.06-0.83,1.67-1.92,1.81-3.28c0.18-1.31-0.14-2.49-0.98-3.56c-0.83-1.06-1.92-1.69-3.28-1.88c-1.3-0.14-2.49,0.21-3.56,1.05
	c-11.74,9.13-25.4,13.69-40.99,13.66c-18.12,0-33.69-6.22-46.71-18.68c-0.96-0.91-2.12-1.35-3.49-1.32
	c-1.32,0.04-2.46,0.55-3.42,1.53C706.11,199.88,705.67,201.01,705.7,202.32 M801.43,84.85c-0.32-1.3-1.07-2.3-2.23-3
	c-11.46-6.63-24.31-9.95-38.55-9.97c-21.43,0-39.74,7.55-54.94,22.66c-3.58,3.64-6.74,7.43-9.48,11.36c-0.75,1.13-1,2.34-0.77,3.63
	c0.25,1.35,0.93,2.39,2.02,3.14c1.13,0.8,2.34,1.08,3.63,0.84c1.34-0.25,2.39-0.95,3.14-2.09c2.42-3.45,5.21-6.78,8.37-9.97
	c13.29-13.2,29.3-19.8,48.04-19.8c12.44-0.02,23.66,2.86,33.67,8.65c1.17,0.7,2.4,0.86,3.7,0.49c1.3-0.32,2.27-1.07,2.93-2.23
	C801.64,87.38,801.8,86.14,801.43,84.85 M854.06,86.8c0.21-1.32-0.09-2.53-0.91-3.63c-3.56-4.82-7.6-9.49-12.13-14.01
	c-22.17-22.17-48.97-33.26-80.39-33.26c-26.05,0.01-48.92,7.63-68.6,22.87c-1.06,0.87-1.69,1.96-1.88,3.28
	c-0.14,1.35,0.21,2.56,1.05,3.63c0.83,1.06,1.9,1.67,3.21,1.81c1.35,0.19,2.56-0.13,3.63-0.98c17.96-13.91,38.83-20.86,62.61-20.85
	c28.72,0,53.22,10.13,73.48,30.4c4.17,4.17,7.88,8.47,11.16,12.9c0.85,1.11,1.94,1.76,3.28,1.95c1.32,0.2,2.5-0.1,3.56-0.91
	C853.22,89.2,853.87,88.13,854.06,86.8 M891.99,203.02c-1.22,0.49-2.11,1.35-2.65,2.58c-6.79,15.58-16.72,29.87-29.77,42.88
	c-27.28,27.33-60.24,40.99-98.86,40.99c-29.8,0.02-56.23-8.06-79.27-24.26c-1.09-0.78-2.3-1.06-3.63-0.84
	c-1.32,0.24-2.36,0.91-3.14,2.02c-0.78,1.1-1.06,2.31-0.84,3.63c0.23,1.32,0.88,2.36,1.95,3.14c24.69,17.36,53,26.05,84.92,26.07
	c41.32,0,76.57-14.62,105.76-43.85c13.95-13.91,24.55-29.2,31.79-45.87c0.54-1.24,0.56-2.49,0.07-3.76
	c-0.49-1.23-1.35-2.11-2.58-2.65C894.52,202.55,893.26,202.53,891.99,203.02 M711.7,16.52c1.2,0.63,2.43,0.73,3.7,0.28
	c14.12-4.7,29.22-7.05,45.32-7.04c38.62,0,71.58,13.64,98.86,40.92c11.54,11.53,20.65,24.05,27.33,37.58
	c0.62,1.21,1.55,2.02,2.79,2.44c1.3,0.45,2.55,0.35,3.76-0.28c1.21-0.57,2.03-1.5,2.44-2.79c0.45-1.25,0.35-2.48-0.28-3.7
	c-7.12-14.46-16.83-27.84-29.14-40.16C837.28,14.59,802.03,0,760.71,0c-17.18,0-33.31,2.51-48.38,7.53
	c-1.27,0.46-2.23,1.3-2.86,2.51c-0.59,1.2-0.68,2.43-0.28,3.7C709.65,15.01,710.48,15.94,711.7,16.52z"/>
</svg>

'''

var svgGroup = insertSvg(svgCode)
var pageItems = svgGroup.pageItems
pageItems[0].pathItems[0].fillColor = '31 91 80 0, 181 63 68'.toAiColor() // 30
pageItems[1].fillColor = '0 0 0 65, 125 125 125'.toAiColor() // line
pageItems[2].pathItems[0].fillColor = '100 65 0 45, 0 30 80'.toAiColor() // vw
pageItems[3].pathItems[0].fillColor = '0 0 0 65, 125 125 125'.toAiColor() // type


function insertSvg(code, color) {
    var svgFileName = "inlineSVGtoAI.svg";
    var svgFile = new File("" + Folder.temp + "/" + svgFileName);
    svgFile.open("w");
    
    svgFile.write(code);
    svgFile.close();

    var doc = app.activeDocument;
    var placed = doc.groupItems.createFromFile(svgFile);

    $.sleep(500);
    svgFile.remove();

    return placed
}

//////////////////////////////////////////////////////////////////////

if (app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {
	var CURR_DOC = app.activeDocument;
	var CURR_ARTBOARD_INDEX = CURR_DOC.artboards.getActiveArtboardIndex()
	var CURR_ARTBOARD = CURR_DOC.artboards[CURR_ARTBOARD_INDEX].artboardRect
  
	// setLogoGroup()
	setYiqiGroup()
  }
  
  /* ============================================================ */
  function setLogoGroup() {
	var artboardSize = _getArtboardSize(CURR_ARTBOARD)
	var artboardShortSide = artboardSize.width < artboardSize.height ? artboardSize.width : artboardSize.height
	var logoGroupScaleRatio = _getLogoRatio(artboardSize)
	var LOGO_RATIO = 0.526314
	var logoGroupHeight = artboardShortSide * logoGroupScaleRatio
	var distance = logoGroupHeight * LOGO_RATIO
	_setSizeAndPosition({x: artboardSize.x + distance, y: artboardSize.y - distance}, logoGroupHeight)
  }
  
  function setYiqiGroup() {
	var artboardSize = _getArtboardSize(CURR_ARTBOARD)
	var artboardShortSide = artboardSize.width < artboardSize.height ? artboardSize.width : artboardSize.height
	var logoGroupScaleRatio = _getLogoRatio(artboardSize)
	var LOGO_RATIO = 0.526314
	var logoGroupHeight = artboardShortSide * logoGroupScaleRatio
	var yiqiGroupHeight = logoGroupHeight * getYiqiRatio(artboardSize)
	var distance = logoGroupHeight * LOGO_RATIO
	var x = artboardSize.x + artboardSize.width - (yiqiGroupHeight * 3.04) - distance;
	var y = artboardSize.y - artboardSize.height + yiqiGroupHeight + (distance / 2)
	_setSizeAndPosition({x: x, y: y}, yiqiGroupHeight)
  }
  
  function _getLogoRatio(rectangle) {
	  var ratioRange =  [1,    4/3,  7/5,  3/2,  16/9, 2,   3,   5,   9,   10];
	  var logoRatios = [[0.4,  0.4,  0.4,  0.4,  0.4,  0.4, 0.4, 0.4, 0.4, 0.4],
						[0.15, 0.15, 0.15, 0.15, 0.15, 0.2, 0.2, 0.3, 0.3, 0.4],
						[0.15, 0.15, 0.15, 0.15, 0.15, 0.2, 0.2, 0.3, 0.3, 0.4]];
	  var W = rectangle.width || 1;
	  var H = rectangle.height || 1;
	  var rectRatio = W > H ? W / H : H / W;
	  var ratioIndex = _getArrIndex_(ratioRange, rectRatio) - 1
	  var typesRange = [130, 560]
	  var shortSide = W < H ? W : H;
	  var typeIndex = _getArrIndex_(typesRange, shortSide)
	  return logoRatios[typeIndex][ratioIndex]
  }
  
  function getYiqiRatio(rectangle) {
	/*
	var ratioRange =  [1,    4/3,  7/5,  3/2,  16/9, 2,   3,   5,   9,   10];
	var yiqiRatios = [[0.8,  0.8,  0.8,  0.8,  0.8,  0.8, 0.8, 0.8, 0.8, 0.8],
					  [0.6,  0.6,  0.6,  0.6,  0.6,  0.6, 0.6, 0.6, 0.6, 0.6]]
	var W = rectangle.width || 1;
	var H = rectangle.height || 1;
	var rectRatio = W > H ? W / H : H / W;
	var ratioIndex = _getArrIndex_(ratioRange, rectRatio) - 1
	*/
	// var typesRange = [240, 560]
	var W = rectangle.width || 1;
	var H = rectangle.height || 1;
	var shortSide = W < H ? W : H;
	return shortSide < 240 ? 0.8 : 0.6
	// var typeIndex = _getArrIndex_(typesRange, shortSide)
	// return yiqiRatios[typeIndex][ratioIndex]
  }
  
  /* ================== Public Base Function ========================================== */
  
  // functions
  // setSizeAndPosition({x: -100, y: 200}, 100)
  /* todo 默认以px为单位，需要增加单位判断 */
  function _setSizeAndPosition (position, height) {
	var doc = app.activeDocument;
	if (doc.selection.length < 1) {
	  alert(':-) 请选好图形后，再试试')
	  return
	}
	var curr = doc.selection[0]
	var ratio = curr.width / curr.height || 1
  
	if  (position) {
	  curr.left = position.x
	  curr.top = position.y
	}
	if (height) {
	  curr.height = height
	  curr.width = height * ratio
	}
  }
  
  function _getArtboardSize(canvas) {
	  var rect = canvas.toString().split(',')
	  var x1 = +rect[0]
	  var y1 = +rect[1]
	  var x2 = +rect[2]
	  var y2 = +rect[3]
	  var rectangle = {
		  y: y1,
		  x: x1,
		  width: Math.abs(x2 - x1),
		  height: Math.abs(y2 - y1)
	  }
	  return rectangle
  }
  
  /* ================== Js untis Functions ========================================== */
  
  function _getArrIndex_(arr, num) {
	var index = 0;
	var len = arr.length
	if (num >= arr[len - 1]) {
	  return len
	}
	  while(arr[index] <= num) {
		  index += 1;
	  }
	  return index;
  }
  
  /* ================== Public Base Function ========================================== */
  